<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .a {
            width: 300px;
            height: 100px;
            background-color: #f00;
            border: 10px solid #000;
            padding: 5px;
        }
    </style>
</head>

<body>

    <div class="a"></div>

    <script>


        // clientWidth / clientHeight  元素包括内边距的宽高

        // offsetWidth / offsetHeight  元素包含内边距和边框的宽高

        

        var oDiv = document.querySelector('.a');

        console.log(oDiv.clientWidth);  // 300

        console.log(oDiv.offsetWidth);

    </script>

</body>

</html>